<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ page import="org.ekingstar.utils.SysArgUtil" language="java"%>
<%@ include file="/common/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src='<s:url value="/scripts/CustomTreeUI.js" includeParams="none"/>'></script>
<script type="text/javascript" src='<s:url value="/pages/querythemes/query/query.js" includeParams="none"/>'></script>
<link rel="stylesheet" type="text/css" href='<s:url value="/scripts/column-tree.css" includeParams="none"/>'/>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/css.css">
<script src='<s:url value="/dwr/interface/commonSearchListService.js" includeParams="none"/>' type="text/javascript"></script>

<title>主题列表</title>
<script>
var typeEqual ="<%=SysArgUtil.typeEqual %>";
var typeNull ="<%=SysArgUtil.typeNull %>";
var typeIn ="<%=SysArgUtil.typeIn %>";
var typeLike ="<%=SysArgUtil.typeLike %>";
var basePath = "<%=basePath%>";
var  highlightcolor='#F8EABE';
//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
var  clickcolor='#fff';
function  changeto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=highlightcolor&&source.id!="nc"&&cs[1].style.backgroundColor!=clickcolor)
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=highlightcolor;
}
}

function  changeback(){
source=event.srcElement;
if  (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="nc")
return
if  (event.toElement!=source&&cs[1].style.backgroundColor!=clickcolor)
//source.style.backgroundColor=originalcolor
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}

function  clickto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=clickcolor&&source.id!="nc")
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=clickcolor;
}
else
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}


function openTree(strCompareCondId){
		if(strCompareCondId=="0000000000"){
			strCompareCondId = document.getElementById("listOrTreeParamIds").value;
		}
		
		var Tree = Ext.tree;
   		var tree = new Tree.TreePanel({       
	        autoScroll:true,
	        animate:true,
	        enableDD:true,
	        containerScroll: true,
	        rootVisible:false,    
	        loader: new Tree.TreeLoader({    
	          dataUrl: '<s:url namespace="/querythemes" action="qdDomainSearch!load4BuilderTree.action?strCompareCondId"/>',    
	          baseParams:{strCompareCondId:strCompareCondId}
      		})
   	 	});
		
   		// set the root node
	    var root = new Tree.AsyncTreeNode({
	        text: '功能',
	        draggable:false,
	        id:'-1'
	    });
	    tree.setRootNode(root);
		
		var win = new Ext.Window({
		                //applyTo     : 'hello-win',
		                title:"选择查询条件",
		                layout      : 'fit',
		                width       : 700,
		                height		:400,
		                closable:false, 
		                closeAction :'close',
		                modal:true, 
		                plain       : true,
		                items:tree,
		                buttons: [
		                 {
		                    text     : '展开',
		                    disabled : false,
		                    handler  :function(){
		                   	tree.root.expand(true,false);
		                    }
		                },
		                {
		                    text     : '收缩',
		                    disabled : false,
		                    handler  :function(){
		                   	tree.root.collapse(true,false);
		                    }
		                },
        
		                {
		                    text     : '确定',
		                    disabled : false,
		                    handler  :function(){                 		                    	
		                    	var ids = "";
		                    	var names = "";
		                    	var checked = [];		                    		                    	
		                    	for (var i = 0; i < tree.getRootNode().childNodes.length; i++){		                    		     
						               checked = checked.concat(getChecked(tree.getRootNode().childNodes[i]));						               
						        }
						        
						        for(var i=0;i<checked.length;i++){
						        	var n = checked[i];
						        	if(ids==""){
						        		ids ="'"+n.id+"'";
						        	}else{
						        		ids = ids +",'"+n.id+"'";
						        	}
						        	
						        	if(names==""){
						        		names =n.text;
						        	}else{
						        		names = names +","+n.text;
						        	}
						        }
						        
						        //document.getElementById("searchConditionValueIds_"+strCompareCondId).value=ids;
	    						//document.getElementById("divid_"+strCompareCondId).innerHTML=names;
	    						document.getElementById("searchConditionValueIds").value=ids;
						        document.getElementById("searchConditionValueCnIds").value=names;
							    document.getElementById("divid_displayName").innerHTML=names;
		                        win.close();
		                    }
		                },
		                {
		                    text     : '取消',
		                    disabled : false,
		                    handler  :function(){		                   
		                    win.close();}
		                }]
		  });	
		  
		 tree.on('checkchange', function(node, checked) { 
			node.expand();    
			node.attributes.checked = checked;    
			node.eachChild(function(child) {             
			child.ui.toggleCheck(checked);               
			child.attributes.checked = checked;   
			child.fireEvent('checkchange', child, checked);          
		});}, tree); 

		tree.on('click', function(node, e) {  
			if (!node.isLeaf()){
				node.toggle(); 
			}
		 });  
		 
	    win.show();
	}
	
	/**  
     * 取得所有子节点中checked为true的节点(TreeNode) 包括本节点  
	 */  
	function getChecked(node){ 
        var checked = [];  
        if (node.getUI().isChecked()){  
           checked.push(node);  
        }  
        if (!node.isLeaf()){  
          for (var i = 0; i < node.childNodes.length; i++){  
               checked = checked.concat(getChecked(node.childNodes[i]));  
          }  
       }  
       return checked;  
   }
	
	
	function doHightSearch(){
		document.getElementById("s_user_form").action="qdDomainSearch!load4HightSearch.action";		
		document.getElementById("s_user_form").submit();
	}
	
	
	
	
	
	
	function tt(sql,ids){
		alert("sql=="+sql);
		alert("ids=="+ids);
	}
	
</script>
</head>
<body onload="initForm()">
<div class="main">
<s:form id="s_user_form" namespace="/querythemes" action="qdDomainSearch!doSearch.action">
<div class="main_title"><b>你当前的位置：</b><s:property value="title" /></div>
	<s:hidden name="pageSize" id="pageSize"/>
	<s:hidden name="qdDomain.id" id="qdDomain.id"/>
	<table align="center"  cellpadding="1" cellspacing="1" width="100%" bgcolor="#C1D1F2" >
	<tr>
		<td width="50%;" style="padding-top:5px" valign="top">
			<table align="center"  cellpadding="2" cellspacing="2" >
				<tr>
				    <td align="left">主题名称:</td>
				    <td align="left" colspan="3"><s:property value="qdDomain.name" /></td>
				</tr>
				<tr>
					<td align="left">条件名称:</td>
				    <td align="left" colspan="4">
				    	<select class="searchSelect" name="searchConditionFieldNames" id="searchConditionFieldIds" onchange="changeField()">
				    		<option value="">---请选择---</option>
				    		<s:iterator value="searchConditionList" status="statust">
						    	<option value="<s:property value="id"/>____<s:property value="TQdComparetype.id"/>____<s:property value="col"/>____<s:property value="autoSingleQuotation"/>"><s:property value="name" /></option>
						    </s:iterator>
				    	</select>				    	
						<s:hidden name="searchConditionChoiceFieldNames" id="searchConditionChoiceFieldIds"></s:hidden>
						<s:hidden name="searchConditionChoiceFieldTypeNames" id="searchConditionChoiceFieldTypeIds"></s:hidden>					    					    	
				    </td>
				</tr>
				<tr>
					<td align="left">条件方式:</td>
				    <td align="left" >
				    	<div id="divid_searchConditionOne">
				    		<s:select cssClass="searchSelect"  name="searchConditionOneNames" id="searchConditionOneIds" list='#{"":"---请选择---","=":"等于","<>":"不等于",">":"大于",">=":"大于等于","<":"小于","<=":"小于等于","like":"包含","is":"为空","is not":"不为空"}'></s:select>
				    	</div>
				    	<div id="divid_searchConditionTwo" style="display:none">
				    		<s:select cssClass="searchSelect"  name="searchConditionTwoNames" id="searchConditionTwoIds" list='#{"":"---请选择---","in":"属于","not in":"不属于"}'></s:select>
				    	</div>
				    </td>
				    <td align="right">条件值:</td>
				    <td align="right" >
				    	<div id="divid_textValue">
				    		<s:textfield cssClass="leaf" name="searchConditionTextValueNames" id="searchConditionTextValueIds"/>
				    	</div>
				    	<div id="divid_singleChoiceValue"  style="display:none">
				    		<s:select cssClass="searchSelect"  name="searchConditionListValueNames" id="searchConditionListValueIds" list='#{"":"---请选择---"}'></s:select>
				    	</div>
				    	<div id="divid_multiChoiceValue"  style="display:none">
				    		<div id="divid_displayName"></div>
				    	</div>				    	
				    	<s:hidden name="searchConditionValueNames" id="searchConditionValueIds"></s:hidden>
				    	<s:hidden name="searchConditionValueCnNames" id="searchConditionValueCnIds"></s:hidden>
				    	
				    	<s:hidden name="hightSearchConditionValueNames" id="hightSearchConditionValueIds"></s:hidden>
				    	<s:hidden name="hightSearchConditionValueCnNames" id="hightSearchConditionValueCnIds"></s:hidden>
				    	<s:hidden name="listOrTreeParamNames" id="listOrTreeParamIds"></s:hidden>
				    </td>
				    <td>
				    	<div id="divid_operater" style="display:none"></div>
				    </td>
				</tr>
					<td colspan="5">
						<input type="button" name="Submit2" value="并且加" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="addCondition(this.form.conditionValueIds,'1')" />										
										
						<input type="button" name="Submit2" value="或者加" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="addCondition(this.form.conditionValueIds,'2')" />										
									
						<input type="button" name="Submit2" value="清除" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="removeoptions(this.form.conditionValueIds,'','')" />										
										
						<input type="button" name="Submit2" value="删除行" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="removeoptions(this.form.conditionValueIds,'3','')" />
						
						<input type="button" name="Submit2" value="+(" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="modifyoptions(this.form.conditionValueIds,'1','')"/>
						
						<input type="button" name="Submit2" value="+)" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="modifyoptions(this.form.conditionValueIds,'2','')"/>
						
						<input type="button" name="Submit2" value="-(" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="modifyoptions(this.form.conditionValueIds,'10','')"/>
						
						<input type="button" name="Submit2" value="-)" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="modifyoptions(this.form.conditionValueIds,'20','')"/>
						
					</td>
				<tr>
				<tr>
					<td colspan="5" align="left">						
					    <s:select cssClass="searchSelect"  name="conditionValueNames" id="conditionValueIds" list='#{}' size="18" multiple="true" style="width:100%"></s:select>				
					</td>
				</tr>
			</table>
		</td>
		<td>
			<table align="center"  cellpadding="0" cellspacing="0" class="tablelist">
				<tr class="listr2">
					<td colspan="4"  style="padding-left:5px">
						<table align="center"  cellpadding="0" cellspacing="0" class="tablelist">
							<tr class="listr2">
								<td align="left">发布字段:</td>
								<td align="center" rowspan="2"  style="width:20%">										
										<input type="button" name="Submit2" value=">" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'"  onclick="srcToDestByHightSearch('qdFieldIds','qdDeployFieldIds','checked','add',this.form.sortFieldIds)" />										
										<br>
										<input type="button" name="Submit2" value=">>" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDestByHightSearch('qdFieldIds','qdDeployFieldIds','all','add',this.form.sortFieldIds)" />										
										<br>
										<input type="button" name="Submit2" value="&lt;" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDestByHightSearch('qdDeployFieldIds','qdFieldIds','checked','del',this.form.sortFieldIds)" />										
										<br>
										<input type="button" name="Submit2" value="<<" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDestByHightSearch('qdDeployFieldIds','qdFieldIds','all','del',this.form.sortFieldIds)"/>							
								</td>				
								<td align="left">已选择的发布字段:	</td>
								<td align="center" rowspan="2" style="width:20%">										
										<input type="button" name="Submit2" value="↑" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="toUpperOrDown('qdDeployFieldIds','step','up')" />										
										<br>
										<input type="button" name="Submit2" value="↑↑" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="toUpperOrDown('qdDeployFieldIds','top','up')" />
										<br>
										<input type="button" name="Submit2" value="↓" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="toUpperOrDown('qdDeployFieldIds','step','down')" />
										<br>
										<input type="button" name="Submit2" value="↓↓" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="toUpperOrDown('qdDeployFieldIds','bottom','down')" />
								</td>
							</tr>
							<tr class="listr2">
								<td align="right">
									<s:select cssClass="searchSelect" name="qdFieldName"  id="qdFieldIds" list="titleFieldList"  listKey="id" listValue="name" size="15" multiple="true" ></s:select>									
								</td>								
								<td align="center">
								   <s:select cssClass="searchSelect"  name="qdDeployFieldName" id="qdDeployFieldIds" list='#{}' size="15" multiple="true" ></s:select>								    
								   <input type="hidden" id="fIds" name="fieldIds" value="">
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr class="listr2">		
					<td style="padding-left:5px">
						<table align="center"  cellpadding="0" cellspacing="0" class="tablelist">
							<tr class="listr2">
								<td align="left">排序字段:</td>
								<td>
									<s:select cssClass="searchSelect"  name="sortFieldNames" id="sortFieldIds" list='#{"":"---请选择---"}'></s:select>
								</td>
								<td>
									<s:select  cssClass="searchSelect"  name="orderByNames" id="orderByIds" list='#{"":"---请选择---","asc":"升序","desc":"降序"}'></s:select>
								</td>
							</tr>
							<tr class="listr2">
								<td align="left">排序字段:</td>
								<td>
									<s:select cssClass="searchSelect"  name="sortFieldNames" id="sortFieldIds" list='#{"":"---请选择---"}'></s:select>
								</td>
								<td>
									<s:select  cssClass="searchSelect"  name="orderByNames" id="orderByIds" list='#{"":"---请选择---","asc":"升序","desc":"降序"}'></s:select>
								</td>
							</tr>
							<tr class="listr2">
								<td align="left">排序字段:</td>
								<td>
									<s:select cssClass="searchSelect"  name="sortFieldNames" id="sortFieldIds" list='#{"":"---请选择---"}'></s:select>
								</td>
								<td>
									<s:select  cssClass="searchSelect"  name="orderByNames" id="orderByIds" list='#{"":"---请选择---","asc":"升序","desc":"降序"}'></s:select>
								</td>
							</tr>
							<tr class="listr2">
								<td align="left">排序字段:</td>
								<td >
									<s:select cssClass="searchSelect"  name="sortFieldNames" id="sortFieldIds" list='#{"":"---请选择---"}'></s:select>
								</td>
								<td >
									<s:select  cssClass="searchSelect"  name="orderByNames" id="orderByIds" list='#{"":"---请选择---","asc":"升序","desc":"降序"}'></s:select>
								</td>
							</tr>
							<tr class="listr2">
								<td align="left">每页记录数:</td>
								<td >
									<s:select id="pageSizeId"  cssClass="searchSelect" list='#{20:"20",50:"50",100:"100",200:"200",300:"300",500:"500"}' name="pageSizeName"></s:select>
							    </td>
							    <td>
							    </td>
							</tr>
						</table>
					</td>			
				</tr>
			</table>
		</td>
	</tr>	
	</table>	
	<div class="tableHeader4">
 		 <table>
 		 	<tr style="width:100%">
 		 		<td style="width:25%">
 		 			&nbsp;
 		 		</td>
 		 		<td style="width:50%">
 		 			<input name="" type="button" value="查 询" class="searchbtn" onmouseover="this.className='searchbtn_hover'" onmouseout="this.className='searchbtn'"   onclick="doSearch()"/>
 		 			&nbsp;
 		 			&nbsp;
 		 			<input name="" type="button" value="返 回" class="back" onmouseover="this.className='back_hover'" onmouseout="this.className='back'"   onclick="goBack()"/>
 		 		</td>
 		 		
 		 		<td align="right">
 		 			&nbsp;
 		 		</td>
 		 	</tr>
 		 </table> 
	</div>
</s:form>
</div>
</body>
</html>